﻿using UnityEngine;
using System.Collections;

public class ItemScript : MonoBehaviour {
	
	playerScript player;
	public int ID;
	//Vector3 goingPos;
	//float lerpPercent;
	//float pickUpSpeed;
	
	// Use this for initialization
	void Start () {
		player = null;
		//lerpPercent = 0;
		//pickUpSpeed = 3;
	}
	
	// Update is called once per frame
	void Update () {
		/*if(isBeingTaken)
		{
			lerpPercent += Time.deltaTime * pickUpSpeed;
			Vector3 tmpPos = Vector3.Lerp(transform.position,goingPos,lerpPercent);
			if(lerpPercent >= 0.98f)
			{
				tmpPos = goingPos;
				isBeingTaken = false;
				player.setDisableControl(false);
				lerpPercent = 0;
			}
			transform.position = tmpPos;
		}*/
	}
	
	void OnTriggerStay(Collider myCollider)
	{
		if(myCollider.tag == "Player")
		{
			//Debug.Log(player);
			if(player == null)
			{
				if(myCollider.networkView.isMine)
					player = myCollider.GetComponent<playerScript>();
			}
			else if(Input.GetKey(KeyCode.F))
			{
				//collider.enabled = false;
				//isBeingTaken = true;
				player.pickUpItem(this);
				transform.position = player.transform.position;
				//myCollider.GetComponent<playerScript>().pickUpItem(this);
				
			}
		}
	}
}
